const { src, dest, parallel } = require('gulp');
const swig = require('gulp-swig');
const sass = require('gulp-sass');
const babel = require('gulp-babel');
const useref = require('gulp-useref');


function compileHtml() {
    return src(['src/**/*.html', '!src/layouts/*.html', '!src/partials/*.html'])
        .pipe(swig())
        .pipe(useref({ searchPath: ['.', '..'] }))
        .pipe(dest('temp/'));
}

function compileStyles() {
    return src('src/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(dest('temp/'));
}

function compileScripts() {
    return src('src/**/*.js')
        .pipe(babel())
        .pipe(dest('temp'));
}

module.exports.compile = parallel(
    compileHtml,
    compileStyles,
    compileScripts
);
module.exports.compileHtml = compileHtml;
module.exports.compileStyles = compileStyles;
module.exports.compileScripts = compileScripts;
